<?php
$line = array('ComID','ComName','StartDate','EndDate','Code','CodeY','Exch','Cat','Type','TimeStamp','LinkedComID','Listed',
'ISIN','GICS','IndustryGroup','Activit','Website','Announce','AnnRep','InvCtr','Email','Rating','CoAddr','CoTel','CoFax','Regry','CoSec');
$csv->addRow($line);
foreach ($codetails as $codetail):
    
	$line = array($codetail['Codetail']['ComID'],
	$codetail['Codetail']['ComName'],
	$codetail['Codetail']['StartDate'],
	$codetail['Codetail']['EndDate'],
	$codetail['Codetail']['Code'],
	$codetail['Codetail']['CodeY'],
	$codetail['Codetail']['Exch'],
	$codetail['Codetail']['Cat'],
	$codetail['Codetail']['Type'],
	$codetail['Codetail']['TimeStamp'],
	$codetail['Codetail']['LinkedComID'],        
	$codetail['Codetail']['Listed'],        
	$codetail['Codetail']['ISIN'],        
	$codetail['Codetail']['GICS'],        
	$codetail['Codetail']['IndustryGroup'],        
	$codetail['Codetail']['Activit'],        
	$codetail['Codetail']['Website'],        
	$codetail['Codetail']['Announce'],   
	$codetail['Codetail']['AnnRep'],        
	$codetail['Codetail']['InvCtr'],        
	$codetail['Codetail']['Email'],        
	$codetail['Codetail']['Rating'],        
	$codetail['Codetail']['CoAddr'],        
	$codetail['Codetail']['CoTel'],        
	$codetail['Codetail']['CoFax'],        
	$codetail['Codetail']['Regry'],        
	$codetail['Codetail']['CoSec']        
	);
	$csv->addRow($line);
        endforeach;
echo $csv->render("codetails.csv");
?>